package com.lancoo.klgcourseware.utils;

import android.content.Context;
import android.os.Environment;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by whyus on 12/27/16.
 */

public class KlgUtils {
    public static Map<String, String> getParams(String str) {
        String[] sArr = str.split("&");
        Map<String, String> map = new HashMap<String, String>();
        for (String s : sArr) {
            String[] ss = s.split("=");
            String key = ss[0];
            String value = ss.length == 2 ? ss[1] : "";
            map.put(key, value);
        }
        return map;
    }

    public static File abainRecordDir(Context context) {
        File targetDir = null;
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            targetDir = new File(Environment.getExternalStorageDirectory(),
                    "Android/data/" + context.getApplicationInfo().packageName + "/files/record");
            if (!targetDir.exists()) {
                targetDir.mkdirs();
            }
        }
        return targetDir;
    }

    private KlgUtils() {
        throw new UnsupportedOperationException("cannot be instantiated");
    }

}
